package net.lab1024.sa.admin.module.business.monitorList.controller;

import net.lab1024.sa.admin.module.business.monitorList.domain.form.MonitorListAddForm;
import net.lab1024.sa.admin.module.business.monitorList.domain.form.MonitorListQueryForm;
import net.lab1024.sa.admin.module.business.monitorList.domain.form.MonitorListUpdateForm;
import net.lab1024.sa.admin.module.business.monitorList.domain.vo.MonitorListVO;
import net.lab1024.sa.admin.module.business.monitorList.service.MonitorListService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 设备列表 Controller
 *
 * @Author 1
 * @Date 2025-07-14 10:19:22
 * @Copyright 1
 */

@RestController
@Tag(name = "设备列表")
public class MonitorListController {

    @Resource
    private MonitorListService monitorListService;

    @Operation(summary = "分页查询 @author 1")
    @PostMapping("/monitorList/queryPage")
    @SaCheckPermission("monitorList:query")
    public ResponseDTO<PageResult<MonitorListVO>> queryPage(@RequestBody @Valid MonitorListQueryForm queryForm) {
        return ResponseDTO.ok(monitorListService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author 1")
    @PostMapping("/monitorList/add")
    @SaCheckPermission("monitorList:add")
    public ResponseDTO<String> add(@RequestBody @Valid MonitorListAddForm addForm) {
        return monitorListService.add(addForm);
    }

    @Operation(summary = "更新 @author 1")
    @PostMapping("/monitorList/update")
    @SaCheckPermission("monitorList:update")
    public ResponseDTO<String> update(@RequestBody @Valid MonitorListUpdateForm updateForm) {
        return monitorListService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author 1")
    @PostMapping("/monitorList/batchDelete")
    @SaCheckPermission("monitorList:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return monitorListService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author 1")
    @GetMapping("/monitorList/delete/{id}")
    @SaCheckPermission("monitorList:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer id) {
        return monitorListService.delete(id);
    }
}
